package zhang.automobileservice;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;

import java.text.SimpleDateFormat;
import java.util.Date;

import bean.NewsBean;
import utils.RequestQueueUtils;

public class NewsDetialActivity extends FarterActivity implements View.OnClickListener {
    private ImageButton news_detail_back;
    private TextView news_title;
    private ImageView imageView;
    private TextView time;
    private ImageView imageView2;
    private TextView visitor;
    private NetworkImageView news_img;
    private WebView content;
    private NewsBean newsBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news_detial);
        initView();
        newsBean = (NewsBean) getIntent().getSerializableExtra("NewsBean");
        news_title.setText(newsBean.getTitle());
        visitor.setText(newsBean.getReply_count());
        RequestQueueUtils.exectueNetWorkImageView(this, newsBean.getTop_image(), news_img);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        time.setText(simpleDateFormat.format(new Date(1000*Long.parseLong(newsBean.getEdit_time()))));
        content.loadData(newsBean.getContent(),"text/html; charset=UTF-8",null);

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.news_detail_back:
                finish();
                break;
        }
    }

    private void initView() {
        news_detail_back = (ImageButton) findViewById(R.id.news_detail_back);
        news_title = (TextView) findViewById(R.id.news_title);
        imageView = (ImageView) findViewById(R.id.imageView);
        time = (TextView) findViewById(R.id.time);
        imageView2 = (ImageView) findViewById(R.id.imageView2);
        visitor = (TextView) findViewById(R.id.visitor);
        news_img = (NetworkImageView) findViewById(R.id.news_img);
        content = (WebView) findViewById(R.id.content);
        news_detail_back.setOnClickListener(this);
    }
}
